package com.example.geange.demo01;

import android.app.Fragment;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.CompoundButton;
import android.widget.ListView;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;


public class Setting extends Fragment{

    Switch newimgSwitch;
    Switch newbackSwitch;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_setting, container, false);
        newimgSwitch = (Switch) view.findViewById(R.id.switch_newspic);
        newbackSwitch = (Switch) view.findViewById(R.id.switch_newsbackground);
        newimgSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (b){
                    MainActivity.loadpic = false;
                    Toast.makeText(getActivity(), "新闻列表不加载图片", Toast.LENGTH_SHORT).show();
                }else {
                    MainActivity.loadpic = true;
                    Toast.makeText(getActivity(), "新闻列表加载图片", Toast.LENGTH_SHORT).show();
                }
            }
        });

        newbackSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (b){
                    MainActivity.webBackground = Color.parseColor("#EBFAC7");
                }else {
                    MainActivity.webBackground = Color.WHITE;
                }
            }
        });
        return view;
    }

}
